package com.tingyuge.base.arithmetic.sort;

import com.tingyuge.base.arithmetic.tools.Asserts;
import com.tingyuge.base.arithmetic.tools.Integers;

import java.util.Arrays;

/**
 * Created by xiaodao
 * date: 2020/4/6
 */
public class Main {

    public static void main(String[] args) {
        Integer[] arr = Integers.random(1000000,1,100);
        Integers.println(arr);
       testSorts(arr,
//               new QuickSort(),
//               new HeapSort(),
               new MergeSort());


    }


    static void testSorts(Integer[] array, Sort... sorts) {
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray));
        }
        Arrays.sort(sorts);

        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }
}
